<%-- 
    eCOM - Adopte un Presta - Mars-Avril 2013
    Document   : monCompte
    Created on : Ven 05, 2013, 16:41:28 PM
    Author     : Kheira, Jef, William, Tuan-Long
--%>



<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@page import="java.util.*"%>
<%@page import="entities.Product"%>
<%@page import="entities.Account"%>
<%@page import="entities.Photo"%>
<%@page import="dao.Idao"%>
<%@page import="dao.DaoJpa"%>
<%@page import="javax.ejb.EJB"%>
<%@page import="servlets.ServletChargementDonnees"%>
<%@page import="servlets.tools.EtatProduct_Translator"%>


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%
    Product p_tmp = new Product();
    String p_first_path = new String("images/stock_images/900x500_2.jpg");
    List<Photo> listephotos = new ArrayList<Photo>();
%>


<html>
    <head>

        <!-- Bonus : Faire en sorte que le titre puisse afficher le nom du compte. Ex : Mon Compte(TL) --> 

        <title>Adopte Un Presta - Mon compte - <c:out value="${account.prenom}"/> <c:out value="${account.nom}"/></title>
        <meta charset="utf-8">
        <meta name="description" content="Site de vente de prestataires">
        <meta name="keywords" content="Prestataire, SSII, recrutement, RH, vente">
        <meta name="author" content="Kheira, Jef, William, Tuan">
        <link rel="stylesheet" href="css/style.css">
        <script src="js/jquery-1.7.1.min.js"></script>
        <script src="js/script.js"></script>
    </head>

    <body>

        <!-- PRO Framework Panel Begin -->
        <div id="advanced">
            <span class="trigger">
                <strong></strong>
                <em></em>
            </span>
            <div class="bg_pro">
                <div class="pro_main">
                    <a href="" class="pro_logo"></a>
                    <ul class="pro_menu">
                        <li>
                            <a href="index.jsp">
                                <img src="images/pro_home.png" alt="">
                            </a>
                        </li>

                        <c:if test="${isLoggedIn == 'true'}">
                            <li style="margin-left: 300px">
                                <a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=displayCart">Mon Panier</a>
                            </li>
                            <li>
                                <a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=afficherMonCompte">Mon Compte</a>
                            </li>
                            <li>
                                <a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=logout">Déconnexion</a>
                            </li>
                        </c:if>
                        <c:if test="${isLoggedIn != 'true'}">
                            <li style="margin-left: 300px">
                                <a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=displayCart">Mon Panier</a>
                            </li>
                            <li>
                                <a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=gotoSubscribe">Inscription</a>
                            </li>
                            <li><a>Se connecter<span></span></a>  
                                <ul>
                                    <form action="/AdopteUnPrestaWA/ServletChargementDonnees?action=login" method="POST">
                                        <div>
                                            <label for="login">Identifiant : </label> <br/>
                                            <input name="login" type="text" size="10" maxlength="255" style="height:15px;font-size:14px;width: 130px"/> <br/><br/>                          
                                        </div>
                                        <div>
                                            <label for="password"> Mot de passe : </label> <br/>
                                            <input name="password" type="password" size="10" maxlength="255" style="height:15px;font-size:14px;width: 130px"/> <br/><br/>
                                        </div>
                                        <input class="btn sign-in" type="submit" value="Connexion" />
                                    </form>
                                </ul>
                            </li>
                        </c:if>
                    </ul>          
                </div>       
            </div>   
        </div>

        <!-- PRO Framework Panel End -->
        <div class="bg-main">

            <!--==============================header=================================-->

            <header>
                <div class="container_24">
                    <div class="wrapper">
                        <div class="grid_13">
                            <h1><a href="index.jsp">Idealex</a></h1>
                        </div>
                        <div class="grid_11">
                            <form action="/AdopteUnPrestaWA/ServletChargementDonnees?action=rechercher" method="POST">
                                <div align="right">
                                    <input style=" font:11px/15px Arial, Helvetica, sans-serif; " type="text" name="search_query">
                                    <input style=" background:#1f2025; font:11px/15px Arial, Helvetica, sans-serif; text-transform:uppercase; color:#eaeaea; padding:8px 8px 8px 8px;" type="submit" value="Rechercher">
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <nav class="main-menu">
                    <ul class="sf-menu">
                        <li><a href="more.jsp"><em>A propos</em><strong></strong></a><ul>
                                <li><a href="more.jsp">Qui sommes-nous ?</a></li>
                                <li><a href="enConstruction.jsp">Nouvelles</a></li>
                                <li><a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=product">Produits</a></li>
                            </ul>
                        </li>
                        <li><a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=product"><em>Produits</em><strong></strong></a><ul>
                                <li><a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=product">Tous</a></li>
                                <li><a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=developer">Développeurs</a></li>
                                <li><a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=projectManager">Chefs de projet</a></li>
                                <li><a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=productManager">Responsables produits</a></li>
                                <li><a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=architect">Architectes</a></li>
                                <li><a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=coach">Coach / Scrum Master</a></li>
                                <li><a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=consultant">Consultants</a></li>
                            </ul>
                        </li>	
                        <li><a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=productStores"><em>Partenaires</em><strong></strong></a></li>
                        <li><a href="enConstruction.jsp"><em>Autres</em><strong></strong></a></li>
                        <li><a href="enConstruction.jsp"><em>Clients</em><strong></strong></a></li>
                        <c:set var="etatUtilisateur" scope="session" property="account.accessLevel" />

                        <c:if test="${account.accessLevel == 2}">
                            <!-- c:out value="Bienvenue super-admin" /> -->
                            <li><a href="super-admin.jsp"><em>Administration</em><strong></strong></a><ul>
                                    <li>Compte</li>
                                    <li><a href="ajoutAccount.jsp">Créer Compte</a></li>
                                    <li><a href="modifAccount.jsp">Modifier/Supprimer</a></li>
                                    <li>ProductStore</li>
                                    <li><a href="ajoutProductStore.jsp">Créer ProductStore</a></li>
                                    <li><a href="modifProductStore.jsp">Modifier/Supprimer</a></li>
                                    <li>Prestataires</li>
                                    <li><a href="ajoutPresta.jsp">Créer Presta</a></li>
                                    <li><a href="modifPresta.jsp">Modifier/Supprimer</a></li>     
                                    <li>Autres</li>	
                                </ul>
                            </li>
                        </c:if>
                        <c:if test="${account.accessLevel == 1}">
                            <!-- c:out value="Bienvenue admin" /> -->                                        
                            <li><a href="admin.jsp"><em>Options</em><strong></strong></a><ul>
                                    <li><a href="ajoutPresta.jsp">Créer Presta</a></li>
                                    <li>Autres</li>						
                                </ul>				
                            </li>	


                        </c:if>
                        <c:if test="${account.accessLevel == 0}">
                            <!-- c:out value="Bienvenue utilisateur" /> -->
                            <li></li>
                        </c:if>
                        <li class="last"><a href="contacts.jsp"><em>Contacts</em><strong></strong></a></li>
                    </ul>
                    <div class="clear"></div>
                </nav>

            </header>
            <!--==============================section=================================-->

            <c:set var="monNom" scope="session" value ="${sessionScope['p_presta']}"/>
            <c:set var="monPrenom" scope="session" value ="${sessionScope['cvOfPresta']}"/>

            <section class="padsection7">
                <div class="container_24">
                    <div class="wrapper"><div class="grid_24">
                        </div>
                    </div>
                </div>
                <div class="tabs tabs4">

                    <div class="tab-content">
                        <div class="container_24">

                            <div class="wrapper">
                                <div class="grid_24">
                                    <h1 class="title3">Bonjour <c:out value="${account.prenom}"/> <c:out value="${account.nom}"/> !</h1>
                                    <br>
                                    <h2>Bienvenue sur votre espace personnel.</h2>

                                </div>
                                <div class="grid_8">
                                    <h3>Informations générales :</h3>
                                    <p>Login : <c:out value="${account.login}"/><br/>
                                        Adresse e-mail : <c:out value="${account.adresse}" /><br>
                                        Type de compte : 
                                        <c:choose>
                                            <c:when test="${account.accessLevel==0}">Utilisateur</c:when>
                                            <c:when test="${account.accessLevel==1}">Administrateur partenaire</c:when>
                                            <c:when test="${account.accessLevel==2}">Administrateur</c:when>
                                        </c:choose>
                                        <br/>
                                    </p>
                                </div>
                                <div class="grid_3">
                                    <br><br>
                                </div>
                                <div class="grid_13">
                                    <h3>Votre solde est de : <c:out value="${account.solde}"/></h3>
                                    <form id="form1" action="/AdopteUnPrestaWA/ServletChargementDonnees?action=monCompte_credit" method="POST">
                                        <label><span class="text-form">Crédits :</span>
                                            <input type="number" id="credits" name="monCompte_credits" required/>
                                        </label>
                                        <img src="images/VisaMasterCard_002.png" alt="">
                                        <input class="btn" type="submit" value="Créditer le compte" />
                                    </form>
                                </div>

                                <div class="grid_24">
                                    <h3>Historique de vos commandes :</h3>
                                    <!-- A faire ! -->
                                    <c:if test="${monCompte_noCommande == 'true'}">
                                        <c:out value="Vous n'avez passé aucune commande à ce jour." />
                                    </c:if>
                                    <c:forEach var="itemc" items="${requestScope['monCompte_lc']}">
                                        <div class="wrapper pad_port">
                                            <c:forEach var="itemp" items="${requestScope['monCompte_lp']}">
                                                <c:if test="${itemp.commandeidCommande == itemc.idCommande}">
                                                    <c:set var="p_item" value="${itemp}" scope="request" />
                                                    <%
                                                        p_tmp = (Product) request.getAttribute("p_item");
                                                        listephotos = (List<Photo>) request.getAttribute("listephotos");
                                                        p_first_path = new String("images/stock_images/900x500_2.jpg");
                                                        if ((p_tmp != null) && (listephotos != null)) {
                                                            Iterator<Photo> itphoto = listephotos.iterator();
                                                            while (itphoto.hasNext()) {
                                                                Photo p_first = itphoto.next();
                                                                if (p_first.getProductidProduct() == p_tmp.getIdProduct()) {
                                                                    p_first_path = p_first.getCheminPhoto();
                                                                }
                                                            }
                                                            request.getSession().setAttribute("p_first_path", p_first_path);
                                                            System.err.print("portfolio_architect.jsp -- p_first_path ==" + p_first_path);
                                                        }
                                                    %>
                                                    <div class='image_left'>
                                                        <a href='${p_first_path}' data-gal="prettyPhoto[gallery8]" class="image_style3 image_with_capt lightbox-image">
                                                            <img height="170" width="150" src='${p_first_path}' alt="">
                                                        </a>
                                                    </div>
                                                    <c:out value="Date de la commande : ${itemc.dateCommande}"/><br>
                                                    <c:out value="Prestataire : ${itemp.prenom} "/><c:out value="${itemp.nom}"/><br>
                                                    <c:out value="Prix : ${itemp.prix}"/>
                                                </c:if>
                                            </c:forEach>
                                        </div>
                                    </c:forEach>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </section>	
        </div>

        <!--==============================footer=================================-->

        <footer>
            <div class=" container_24">
                <div class="wrapper">
                    <div class="grid_6 suffix_2">
                        <h1 class="footer-logo"><a href="index.jsp">idealex</a></h1>
                        <p>Adopte Un Presta</p>
                        <p class="color1 privacy">&copy; 2013 <span>|</span>  <a href="/AdopteUnPrestaWA/ServletChargementDonnees?action=politiqueConf">Politique de confidentialité</a> <!-- {%FOOTER_LINK} --></p>
                    </div>
                    <div class="grid_7 suffix_2">
                        <h4>Liens connexes</h4>
                        <div class="wrapper">
                            <div class="grid_4 alpha">
                                <ul class="footer-list">
                                    <li><a href="more.jsp">A propos de nous</a></li>
                                    <li><a href="more.jsp">Notre concept</a></li>
                                    <li><a href="more.jsp">Nos partenaires</a></li>
                                    <li><a href="more.jsp">Evénements &amp; Press</a></li>
                                    <li><a href="more.jsp">Nous contacter</a></li>
                                </ul>
                            </div>
                            <div class="grid_3 omega">
                                <ul class="footer-list">
                                    <li><a href="more.jsp">Se connecter</a></li>
                                    <li><a href="more.jsp">Forums</a></li>
                                    <li><a href="more.jsp">Programme de fidélité</a></li>
                                    <li><a href="more.jsp">FAQ</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="grid_7">
                        <h4>Nous suivre</h4>
                        <ul class="tooltips">
                            <li><a href="more.jsp"><img src="images/icon1.png" alt=""><span>RSS</span></a></li>
                            <li><a href="more.jsp"><img src="images/icon3.png" alt=""><span>Facebook</span></a></li>
                            <li><a href="more.jsp"><img src="images/icon2.png" alt=""><span>Twitter</span></a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </footer>
    </body>
</html>


